package com.ydw.aware;

import com.ydw.event_.MyEvent;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;

/**
 * @author HYL
 * @create 2017-07-06 下午10:54
 **/
@Service
public class MyAwareService implements ApplicationEventPublisherAware,ResourceLoaderAware,BeanNameAware{
    private String beanName;
    private ResourceLoader resourceLoader;
    private ApplicationEventPublisher tradeEventPublisher;


    @Override
    public void setResourceLoader(ResourceLoader resourceLoader) {
        this.resourceLoader=resourceLoader;
    }

    @Override
    public void setBeanName(String s) {
        this.beanName=s;
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.tradeEventPublisher=applicationEventPublisher;
    }

    public void publishEvent(){
        this.tradeEventPublisher.publishEvent(new MyEvent(this,"hello"));
    }
}
